import Vue from 'vue'//1.引入vue
import VueRouter from 'vue-router'//2.引入路由
import home from '../views/home/home.vue'
import news from '../views/home/news/news.vue'
import personal from '../views/personal/personal.vue'
import shopCar from '../views/shopCar/shopCar.vue'
import search from '../views/search/search.vue'
import detail from '../views/home/detail/detail.vue'
import photo from '@/views/home/photo/photo.vue'
import photoList from '@/views/home/photo/photoList.vue'
import goods from '@/views/home/goods/goods/goods.vue'
import goodsDetail from '@/views/home/goods/goods_Detail/goods_Detail.vue'
Vue.use(VueRouter)//5.使用路由
//3定义规则并实例化路由
const router = new VueRouter({
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    //路由重定向
    {
      path: '/home',
      component: home,
      //给每个路由携带一个meta信息
      meta: {
        title: '主页',
        active: 0
      }
    },
    {
      path: '/home/newslist',
      component: news,
      meta: {
        title: '新闻'
      }
    },
    {
      path: '/personal',
      component: personal,
      meta: {
        title: '个人中心',
        active: 1
      }
    },
    {
      path: '/shopCar',
      component: shopCar,
      meta: {
        title: '购物车',
        active: 2
      }
    },
    {
      path: '/search',
      component: search,
      meta: {
        title: '搜索',
        active: 3
      }
    },
    {
      path: '/home/detail/:id',
      props: true,
      component: detail,
      meta: {
        title: '新闻详情'
      }
    },
    {
      path: '/home/photolist',
      component: photo,
      meta: {
        title: '图片列表'
      }
    },
    {
      path: '/home/photoList/:id',
      props: true,
      component: photoList,
      meta: {
        title: '图片详情'
      }
    },
    {
      path: '/home/goodslist',
      component: goods,
      meta: {
        title: '商品列表'
      }
    },
    {
      path: '/home/goodslist/:id',
      props: true,
      component: goodsDetail,
      meta: {
        title: '商品详情'
      }
    }
  ]
})
export default router//4暴露路由